package com.seabook.store.auth.web;

import javax.servlet.http.HttpServletRequest;


import com.seabook.store.auth.domain.User;
import com.seabook.store.purchase.domain.Cart;

public class UserSession {
    private User user = null;
    
    private Cart cart = new Cart();

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Cart getCart() {
        return cart;
    }

    public void setCart(Cart cart) {
        this.cart = cart;
    }
    
    public static UserSession getUserSession(HttpServletRequest request){
        UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
        if(null == userSession){
            userSession = new UserSession();
            request.getSession().setAttribute("userSession", userSession);
        }
        return userSession;
    }
    
    public static void invalid(HttpServletRequest request){
        request.getSession().removeAttribute("userSession");       
    }
   
}
